<template>
  <div class="test">

    <div>
      班组线体信息
    </div>

    <RenderTable 
      ref="renderTable"
      :superQueryFieldList="superQueryFieldList" 
      :queryParamArr = "queryParamArr"
      :defColumns="defColumns"
      :rowSelectionType = "'radio'"
      :isShowRowSelection = 'true'
      :url = "url"
      @onSelectChange = 'onSelectChange'
      @handleEdit = "handleEdit"
    >
      <div slot="btn">
        <p-button type="primary" @click="showAddModal">新增</p-button>
      </div>
    </RenderTable>

    <ClassLineInfoModal ref='classLineInfoModal' @handleSuccess = 'handleSuccess'></ClassLineInfoModal>

    <div>
      班组人员分配
    </div>

    <ClassLineInfoEmp v-if="seletedclassno != ''" ref="classLineInfoEmp" :classno = "seletedclassno"> </ClassLineInfoEmp>


  </div>
</template>

<script type="text/javascript">

import RenderTable from '@/components/renderTable'
import ClassLineInfoModal from './modules/classLineInfoModal.vue'
import ClassLineInfoEmp from './modules/classLineInfoEmp.vue'

const superQueryFieldList =
[
  {
    value: "organization",
    text: "组织",
    type: "String",
  },  
  {
    value: "empname",
    text: "员工姓名",
    type: "String",
  },
]
export default {
  data() {
    return {
      superQueryFieldList,
      queryParamArr: [
        {
          label: "班组编码",
          placeholder: "请输入班组编码",
          type: 'input',
          key: 'classno',
          value: ''
        },
        {
          label: "班组名称",
          placeholder: "请输入班组名称",
          type: 'input',
          key: 'classname',
          value: ''
        },
      ],
      defColumns: [
        {
          title: "序号",
          dataIndex: "",
          key: "rowIndex",
          width: 60,
          align: "center",
          customRender: (t, r, index) => {
            return parseInt(index) + 1;
          },
        },
        {
          title: "车间",
          align: "center",
          dataIndex: "workroomname",
        },
        {
          title: "二级班组编码",
          align: "center",
          dataIndex: "classno",
        },
        {
          title: "二级班组名称",
          align: "center",
          dataIndex: "classname",
        },
        {
          title: "二级班组描述",
          align: "center",
          dataIndex: "classdescription",
        },
        {
          title: "线体",
          align: "center",
          dataIndex: "linename",
        },
        {
          title: "创建人",
          align: "center",
          dataIndex: "createBy",
        },
        {
          title: "创建时间",
          align: "center",
          dataIndex: "createTime",
        },
        {
          title: "状态",
          align: "center",
          dataIndex: "status",
          scopedSlots: { customRender: "status" },
        },
        {
          title: "操作",
          dataIndex: "action",
          align: "center",
          scopedSlots: { customRender: "action" },
        },
      ],
      seletedclassno: '',
      url: {
        list: '/mes-manpower/mesHrClassLineInfo/list',
        editStatus: '/mes-manpower/mesHrClassLineInfo/status',
        delete: '/mes-manpower/mesHrClassLineInfo',
      },

      layout: {
        labelCol: { span: 4 },
        wrapperCol: { span: 14 },
      },         
    }
  },
  mounted() {

  },
  methods: {
    handleEdit(record){
      console.log(record);
      
      this.$refs.classLineInfoModal.showModal(record)
    },
    showAddModal(){
      this.$refs.classLineInfoModal.showModal()
    },
    handleSuccess(){
      this.$refs.renderTable.loadData(1)
    },
    onSelectChange(selectionRows){
      console.log(selectionRows);
      this.seletedclassno = selectionRows[0].id
    }
  },
  components: {
    RenderTable,
    ClassLineInfoModal,
    ClassLineInfoEmp
  }
}
</script>

<style lang="less" scoped>
</style>

